package com.cw.controller;

import com.cw.common.api.*;
import com.cw.dto.WorkSumReportCondition;
import com.cw.request.*;
import com.cw.service.*;
import io.swagger.annotations.*;
import java.io.*;
import javax.servlet.http.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.*;

/**
 * @Description:
 * @Author: smq
 * @Time: 2021/5/14 16:27
 */
@Api(tags = {"报表统计"})
@RestController
@RequestMapping("/dataSource")
public class DataSourceController {

    @Autowired
    private IThisIiPrepayinService targetService;

    @Autowired
    private ReportService reportService;

//    @ApiOperation(value = "获取空床报表数据")
    @PostMapping("/getDataSource")
    public ResultObject getDataSource(@RequestBody DataSourceRequest dataSourceRequest) {
        return ResultObject.successReturn(targetService.getDataSource(dataSourceRequest));
    }

//    @ApiOperation(value = "获取空床报表数据")
//    @PostMapping("/getEmptyBedReportNew")
//    public ResultObject getEmptyBedReportNew(@RequestBody DataSourceRequest dataSourceRequest) {
//        return ResultObject.successReturn(targetService.getEmptyBedReportNew(dataSourceRequest));
//    }


    @ApiOperation(value = "导出空床报表数据")
    @PostMapping("/downDataSourceFormExcel")
    public void downDataSourceFormExcel(@RequestBody DataSourceRequest dataSourceRequest) throws IOException {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletResponse response = servletRequestAttributes.getResponse();
        targetService.downDataSourceFormExcel(response, dataSourceRequest);
    }

    @ApiOperation("获取集管床位计算报表数据")
    @PostMapping("/getManageBedCalculationDTO")
    public ResultObject getManageBedCalculationDTO(@RequestBody DataSourceRequest dataSourceRequest) {
        return ResultObject.successReturn(reportService.getManageBedCalculationDTO(dataSourceRequest));
    }

    @ApiOperation("获取集管床位计算报表数据")
    @PostMapping("/getManageBedCalculationDtoExcel")
    public void getManageBedCalculationDtoExcel(@RequestBody DataSourceRequest dataSourceRequest) throws IOException {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletResponse response = servletRequestAttributes.getResponse();
        reportService.getManageBedCalculationDtoExcel(dataSourceRequest, response);
    }

    @ApiOperation("个人工作量统计")
    @PostMapping("/getWorkSumReportDto")
    public ResultObject getWorkSumReportDto(@RequestBody WorkSumReportCondition condition) {
        return ResultObject.successReturn(reportService.getWorkSumReportDto(condition));
    }

    @ApiOperation("个人工作量统计报表")
    @PostMapping("/getWorkSumReportDtoExcel")
    public void getWorkSumReportDtoExcel(@RequestBody WorkSumReportCondition condition) throws IOException {
        reportService.getWorkSumReportDtoExcel(condition);
    }

    @ApiOperation("科室床位预约统计")
    @PostMapping("/getDeptUsedBedReportDTO")
    public ResultObject getDeptUsedBedReportDTO(@RequestBody WorkSumReportCondition condition) {
        return ResultObject.successReturn(reportService.getDeptUsedBedReportDTO(condition));
    }

    @ApiOperation("科室床位预约统计excel")
    @PostMapping("/getDeptUsedBedReportDtoExcel")
    public void getDeptUsedBedReportDtoExcel(@RequestBody WorkSumReportCondition condition) throws IOException {
        reportService.getDeptUsedBedReportDtoExcel(condition);
    }

}
